<?php
//发送Post请求修改DNS请求

function post( $post_data, $url)
{
	
	$ch_curl = curl_init ();
	curl_setopt ( $ch_curl, CURLOPT_TIMEOUT, 60);//3s
	curl_setopt ( $ch_curl, CURLOPT_HEADER, false );
	//if(is_array($post_data)){
		curl_setopt ( $ch_curl, CURLOPT_POST , 1);
		curl_setopt ( $ch_curl, CURLOPT_POSTFIELDS , $post_data);
	//}else{
	//	curl_setopt ( $ch_curl, CURLOPT_POST , 0);
	//}
	curl_setopt ( $ch_curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt ( $ch_curl, CURLOPT_RETURNTRANSFER, true );
	curl_setopt ( $ch_curl, CURLOPT_URL, $url );
	
	$str_return = curl_exec ( $ch_curl );
	
	
	 $curl_errno = curl_errno($ch_curl);  
     $curl_error = curl_error($ch_curl);  
	if($curl_errno > 0){
		var_dump($curl_errno);	
		var_dump($curl_error);	
	}
	
	
	//$info = json_decode($str_return);
		
	return $str_return;
		
	//var_dump($str_return);
	//exit();
		
	
		// 1. 初始化
	$ch = curl_init();
	// 2. 设置选项，包括URL
	curl_setopt($ch, CURLOPT_HEADER,0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
	curl_setopt($ch, CURLOPT_POST, 1); 
	curl_setopt($ch, CURLOPT_URL, "https://api.o-tap.cn/Device/iPhone/Check/Login");
	//curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);  
	// 3. 执行并获取HTML文档内容
	$output = curl_exec($ch);
	// 4. 释放curl句柄
	$s = curl_getinfo($ch);
    //$result = curl_exec($ch);  

//	var_dump($post_data);
//	var_dump($url);
	
	print_r($output);
	
	print_r($s);
	exit();
	return $output;

    //初始化一个CURL对象
    $curl = curl_init();

    //设置提交网页,http/https都可以
    curl_setopt($curl, CURLOPT_URL, $url);

    //设置是否返回header
    //curl_setopt($curl, CURLOPT_HEADER, 1);

    //设置结果返回到字符串还是输出到屏幕，这里我们返回到字符串
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    //设置POST提交
    curl_setopt($curl, CURLOPT_POST, 1);

    //设置提交的数据
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);

    //执行发送请求
    $data = curl_exec($curl);

    //显示获得数据
    return $data;

}



?>
